package com.itxx.allTools.test.recursion;
//递归求阶乘
public class Recursion {
    public static void main(String[] args) {
        int sum = getRecursionSum(13);
        int sum1 = getRecursionSum(12);
        System.out.println(sum);
        System.out.println(sum1);
    }

    private static int getRecursionSum(int i) {
        /*//
        i=12-> 12*getRecursionSum(11)
        i=11-> 11*getRecursionSum(10)
                ...
        i=2-> 2*getRecursionSum(1)
        i=1->   retrun 1
        */
        if (i == 1) {
            return 1;
        } else {
            return i * getRecursionSum(i - 1);
        }
    }
}
